1. Field of the Invention
Methods and apparatuses consistent with the present invention relate to encoding and decoding an image, and more particularly, to encoding transform coefficient information when an image is encoded, and decoding the transform coefficient information.
2. Description of the Related Art
An image compression technique such as H.264/Moving Picture Experts Group-4 (MPEG-4) Advanced Video Coding (AVC) divides an image in units of block having a predetermined size, and performs inter prediction or intra prediction in block units, thereby generating a prediction image. Afterward, the image compression technique transforms a residual that is a difference value between the prediction image and an original image, and performs quantization and variable length coding on the residual value, thereby performing encoding. For example, in the H.264/MPEG-4 AVC, discrete cosine transformation (DCT) and quantization are performed in units of residual blocks having a 4×4 size, and then a syntax element of residual data is generated for each 4×4 residual block unit. Examples of the syntax elements of 4×4 residual blocks defined in H.264 are coded_block_flag, significant_coeff_flag[i], coeff_sign_flag[i], and the like.
FIG. 1 is a flowchart of a related art method of encoding transform coefficients.
Referring to FIG. 1, coded_block_flag is encoded, wherein the coded_block_flag indicates whether a non-zero transform coefficient value exists in 16 quantized transform coefficients included in a 4×4 transform coefficient block that is obtained by transforming and quantizing a residual block having a 4×4 size. When the coded_block_flag is 0, this means that there is no more information to be transmitted in the given 4×4 transform coefficient block. In operation 10, when a non-zero transform coefficient (hereinafter, referred to as ‘a significant coefficient’) exists in the 4×4 transform coefficient block, the coded_block_flag is set as 1, and a significant map indicating a position of the significant coefficient is generated. The significant map indicates whether a transform coefficient according to each scan index is the significant coefficient or 0, and uses significant_coeff_flag[i] for the indication. Here, the significant_coeff_flag[i] indicates whether a transform coefficient value of an ith scan index from among the 16 quantized transform coefficients in the 4×4 transform coefficient block is 0 or not.
In operation 11, an end of block (EOB) flag is generated so as to indicate whether each significant coefficient is a last significant coefficient in the 4×4 transform coefficient block. If the EOB flag is 1, a corresponding significant coefficient is the last significant coefficient in the 4×4 transform coefficient block. If the EOB flag is 0, a corresponding significant coefficient is not the last significant coefficient.
In operation 12, a Greater than 1 (GR1) flag is generated so as to indicate whether an absolute value of each significant coefficient has a value greater than 1. If the GR1 flag is 1, a corresponding significant coefficient has an absolute value greater than 1. If the GR1 flag is 0, this means that an absolute value of a corresponding significant coefficient is 1.
In operation 13, magnitude information of the significant coefficient having the GR1 flag that is 1, in other words, the magnitude information of the significant coefficient having an absolute value greater than 1, is encoded. At this time, in order to save the number of bits allocated to the magnitude information, a difference value obtained by subtracting 2 from an absolute value of the significant coefficient is generally encoded as the magnitude information.
In operation 14, sign information of each significant coefficient existing in the 4×4 transform coefficient block is encoded.
FIG. 2A is an example of a related art 4×4 transform coefficient block. FIG. 2B is an example of a significant map corresponding to the 4×4 transform coefficient block of FIG. 2A.
Referring to FIGS. 2A and 2B, while each of the transform coefficients in a 4×4 transform coefficient block 21 is scanned according to a predetermined scan order based on an arrow direction illustrated in FIG. 2A, a significant coefficient is marked as 1 and a zero transform coefficient is marked as 0 so that a significant map 22 is generated.
To be more specific, referring to FIG. 3, the 4×4 transform coefficient block 21 illustrated in FIG. 2A is scanned according to the predetermined scan order so that the transform coefficients are arrayed in a one-dimensional array 310. From among the transform coefficients arrayed in the one-dimensional array 310, the significant coefficient is marked as 1, and the zero transform coefficient is marked as 0 so that a one-dimensional significant map 320 is generated. An EOB flag 330, indicating whether each of significant coefficients is a last significant coefficient, is allocated to each of the significant coefficients having a value 1 in the significant map 320. Also, for each of the significant coefficients, 1 is allocated to a significant coefficient having an absolute value greater than 1, and 0 is allocated to a significant coefficient having an absolute value less than 1 so that a GR1 flag 340 is generated. Afterward, magnitude information 350 is generated by subtracting 2 from an absolute value of a significant coefficient having a GR1 flag that is a value 1. As illustrated in FIG. 3, a value 1 is generated as magnitude information of the first transform coefficient having the value 3, wherein the value 1 is obtained by subtracting 2 from an absolute value 3 of a first transform coefficient which has a value 3 and which is from among the transform coefficients arrayed in the one-dimensional array 310. A value 0, obtained by subtracting 2 from an absolute value 2 of a fourth transform coefficient, is generated as magnitude information of the fourth transform coefficient having the value 2.
In this manner, the related art method divides transform coefficients into non-zero significant coefficients and zero transform coefficients, and encodes positions and magnitude information of the non-zero significant coefficients as transform coefficient information. However, in the case where the non-zero significant coefficients have a broad distribution, that is, in the case where a difference between each of absolute values of the non-zero significant coefficients is great, the related art method is not efficient when Context Adaptive Binary arithmetic Coding (CABAC) with respect to the significant map is performed. This is because it is difficult to select an appropriate probability model for encoding the non-zero significant coefficients when the difference between each of the non-zero significant coefficients is great.